﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatterns.Singleton
{
    /// <summary>
    /// 饿汉模式，浪费内存
    /// </summary>
    public class EagerSingleton
    {
        // 构造方法必须对外关闭
        private EagerSingleton() { }

        // 定义一个静态变量用来保存实例
        private readonly EagerSingleton instance = new EagerSingleton();

        /// <summary>
        /// 定义属性方便外部获取
        /// </summary>
        public EagerSingleton Instance 
        { get
            {
                return instance;
            }
        }
    }
}
